<?php

class Utilities{
	
	/**
	 * returns the actual name of the variable, useful for debugging purposes,
	 * or identifiying which variable is empty
	 * 
	 * @author lucas.karisny@linuxmail.org (from http://www.php.net/manual/en/language.variables.php#49997)
	 * 
	 * @param $var
	 * @return variable name 
	 */
	public static function vname(&$var, $scope=false, $prefix='unique', $suffix='value')
  	{
   		if($scope) $vals = $scope;
   		else      $vals = $GLOBALS;
   		$old = $var;
   		$var = $new = $prefix.rand().$suffix;
   		$vname = FALSE;
   		foreach($vals as $key => $val) {
     		if($val === $new) $vname = $key;
   		}
   		$var = $old;
   		return $vname;
  	}
  	
  	/**
  	 * strips all tags from the passed paramater, as well as white space.
  	 * Useful for checking whether a value contains any content
  	 * 
  	 * @param $input
  	 * @return $input without tags and whitespace
  	 */
  	public static function stripTagsAndWhitespace($input){
  		
  		$new_value = strip_tags($input);
		$new_value = str_replace("&nbsp;", "", $new_value);
		$new_value = trim($new_value);
		  			
  		return $new_value;
  	}
  	
}
?>
